package com.excel;

import java.util.ArrayList;
import java.util.List;

public class SimpleExcelColumn extends ExcelColumn {

    private String columnName;
    private String columnDisplayName;

    @Override
    protected List<ExcelColumn> getColumns() {
	List<ExcelColumn> list = new ArrayList<ExcelColumn>();
	list.add(this);
	return list;
    }

    protected List<String> getColumnNames() {
	List<String> list = new ArrayList<String>();
	list.add(columnName);
	return list;
    }

    /**
     * 通过字符串格式合并列
     * 
     * @param formatNames
     *                格式为：(columnDisplay1:columnField)
     */
    protected void mergeColumn(String formatNames) {
	int leftFlag = formatNames.indexOf(Constant.HEADFORMAT_SPRACELEFT_FLAG);
	int rightFlag = formatNames
		.lastIndexOf(Constant.HEADFORMAT_SPRACERIGHT_FLAG);
	String columns = formatNames.substring(leftFlag + 1, rightFlag);	
	int aIndex = columns.indexOf(Constant.FIELD_DISPLAY_SPLIT_FLAG);
	String displayName = columns.substring(0, aIndex);
	String fieldName = columns.substring(aIndex + 1);
	this.displayName = displayName;
	columnName = fieldName;
	columnDisplayName = displayName;

    }

    public String getColumnName() {
	return columnName;
    }

    public void setColumnName(String columnName) {
	this.columnName = columnName;
    }

    public String getColumnDisplayName() {
	return columnDisplayName;
    }

    public void setColumnDisplayName(String columnDisplayName) {
	this.columnDisplayName = columnDisplayName;
    }

}
